home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the 3D Game Programming Gurus / gurus.iso / DirectX / dx9sdkcp.exe / SDK (C++) / Bin / DXUtils / dp8sim.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-12-07  |  7.5 KB  |  217 lines

  1. /***************************************************************************
  2.  *
  3.  *  Copyright (C) 2001-2002 Microsoft Corporation.  All Rights Reserved.
  4.  *
  5.  *  File:        dp8sim.h
  6.  *
  7.  *  Content:    Header for using DP8Sim.
  8.  *
  9.  ***************************************************************************/
  10.  
  11.  
  12.  
  13. #ifndef __DP8SIM_H__
  14. #define __DP8SIM_H__
  15.  
  16.  
  17.  
  18. #include <ole2.h>    // for DECLARE_INTERFACE and HRESULT
  19.  
  20.  
  21.  
  22.  
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26.  
  27.  
  28.  
  29.  
  30.  
  31. /****************************************************************************
  32.  *
  33.  * DP8Sim simulated service providers
  34.  *
  35.  ****************************************************************************/
  36.  
  37. // {8D3F9E5E-A3BD-475b-9E49-B0E77139143C}
  38. DEFINE_GUID(CLSID_NETWORKSIMULATOR_DP8SP_TCPIP, 
  39. 0x8d3f9e5e, 0xa3bd, 0x475b, 0x9e, 0x49, 0xb0, 0xe7, 0x71, 0x39, 0x14, 0x3c);
  40.  
  41.  
  42.  
  43.  
  44.  
  45. /****************************************************************************
  46.  *
  47.  * DP8Sim control object class ID
  48.  *
  49.  ****************************************************************************/
  50.  
  51. // {40530071-1A80-4420-9B74-6A73171B0876}
  52. DEFINE_GUID(CLSID_DP8SimControl, 
  53. 0x40530071, 0x1a80, 0x4420, 0x9b, 0x74, 0x6a, 0x73, 0x17, 0x1b, 0x8, 0x76);
  54.  
  55.  
  56.  
  57.  
  58.  
  59. /****************************************************************************
  60.  *
  61.  * DP8Sim Control interface ID
  62.  *
  63.  ****************************************************************************/
  64.  
  65. // {9CC03740-A510-4bcc-A014-776304B6E0D9}
  66. DEFINE_GUID(IID_IDP8SimControl, 
  67. 0x9cc03740, 0xa510, 0x4bcc, 0xa0, 0x14, 0x77, 0x63, 0x4, 0xb6, 0xe0, 0xd9);
  68.  
  69.  
  70.  
  71.  
  72. /****************************************************************************
  73.  *
  74.  * DP8Sim Control suggested packet header sizes
  75.  *
  76.  ****************************************************************************/
  77.  
  78. #define DP8SIMPACKETHEADERSIZE_IP        20
  79. #define DP8SIMPACKETHEADERSIZE_UDP        8
  80. #define DP8SIMPACKETHEADERSIZE_IP_UDP    (DP8SIMPACKETHEADERSIZE_IP + DP8SIMPACKETHEADERSIZE_UDP)
  81.  
  82.  
  83.  
  84.  
  85.  
  86. /****************************************************************************
  87.  *
  88.  * DP8Sim Control structures
  89.  *
  90.  ****************************************************************************/
  91.  
  92. typedef struct _DP8SIM_PARAMETERS
  93. {
  94.     DWORD    dwSize;                    // size of this structure, must be filled in prior to calling GetAllParameters or SetAllParameters
  95.     DWORD    dwFlags;                // flags for this structure
  96.     DWORD    dwPacketHeaderSize;        // fixed underlying transport packet header size to add into calculations, or 0 to calculate based only on DirectPlay headers and payload
  97.     DWORD    dwBandwidthBPS;            // bandwidth in bytes per second, or 0 for no limit
  98.     FLOAT    fPacketLossPercent;        // percentage of packets to drop, between 0.0 and 100.0
  99.     DWORD    dwMinLatencyMS;            // minimum artificial latency, in milliseconds (on top of any caused by bandwidth settings)
  100.     DWORD    dwMaxLatencyMS;            // maximum artificial latency, in milliseconds (on top of any caused by bandwidth settings)
  101. } DP8SIM_PARAMETERS, * PDP8SIM_PARAMETERS;
  102.  
  103. typedef struct _DP8SIM_STATISTICS
  104. {
  105.     DWORD    dwSize;                    // size of this structure, must be filled in prior to calling GetAllStatistics
  106.     DWORD    dwFlags;                // flags for this structure
  107.     DWORD    dwTransmittedPackets;    // number of packets sent/received
  108.     DWORD    dwTransmittedBytes;        // number of bytes sent/received
  109.     DWORD    dwDroppedPackets;        // number of packets intentionally dropped
  110.     DWORD    dwDroppedBytes;            // number of bytes intentionally dropped
  111.     DWORD    dwTotalDelayMS;            // total number of milliseconds delay added because of bandwidth limitations or random latency settings
  112. } DP8SIM_STATISTICS, * PDP8SIM_STATISTICS;
  113.  
  114.  
  115.  
  116.  
  117.  
  118. /****************************************************************************
  119.  *
  120.  * DP8Sim Control application interfaces
  121.  *
  122.  ****************************************************************************/
  123.  
  124. #undef INTERFACE
  125. #define INTERFACE IDP8SimControl
  126. DECLARE_INTERFACE_(IDP8SimControl, IUnknown)
  127. {
  128.     /*** IUnknown methods ***/
  129.     STDMETHOD(QueryInterface)                (THIS_ REFIID riid, LPVOID * ppvObj) PURE;
  130.     STDMETHOD_(ULONG,AddRef)                (THIS) PURE;
  131.     STDMETHOD_(ULONG,Release)                (THIS) PURE;
  132.  
  133.     /*** IDP8SimControl methods ***/
  134.     STDMETHOD(Initialize)                    (THIS_ const DWORD dwFlags) PURE;
  135.     STDMETHOD(Close)                        (THIS_ const DWORD dwFlags) PURE;
  136.     STDMETHOD(GetAllParameters)                (THIS_ DP8SIM_PARAMETERS * const pdp8spSend, DP8SIM_PARAMETERS * const pdp8spReceive, const DWORD dwFlags) PURE;
  137.     STDMETHOD(SetAllParameters)                (THIS_ const DP8SIM_PARAMETERS * const pdp8spSend, const DP8SIM_PARAMETERS * const pdp8spReceive, const DWORD dwFlags) PURE;
  138.     STDMETHOD(GetAllStatistics)                (THIS_ DP8SIM_STATISTICS * const pdp8ssSend, DP8SIM_STATISTICS * const pdp8ssReceive, const DWORD dwFlags) PURE;
  139.     STDMETHOD(ClearAllStatistics)            (THIS_ const DWORD dwFlags) PURE;
  140. };
  141.  
  142.  
  143.  
  144.  
  145. /****************************************************************************
  146.  *
  147.  * DP8Sim Control application interface macros
  148.  *
  149.  ****************************************************************************/
  150.  
  151. #if (! defined(__cplusplus) || defined(CINTERFACE))
  152.  
  153. #define IDP8SimControl_QueryInterface(p,a,b)            (p)->lpVtbl->QueryInterface(p,a,b)
  154. #define IDP8SimControl_AddRef(p)                        (p)->lpVtbl->AddRef(p)
  155. #define IDP8SimControl_Release(p)                        (p)->lpVtbl->Release(p)
  156. #define IDP8SimControl_Initialize(p,a)                    (p)->lpVtbl->Initialize(p,a)
  157. #define IDP8SimControl_Close(p,a)                        (p)->lpVtbl->Close(p,a)
  158. #define IDP8SimControl_GetAllParameters(p,a,b,c)        (p)->lpVtbl->GetAllParameters(p,a,b,c)
  159. #define IDP8SimControl_SetAllParameters(p,a,b,c)        (p)->lpVtbl->SetAllParameters(p,a,b,c)
  160. #define IDP8SimControl_GetAllStatistics(p,a,b,c)        (p)->lpVtbl->GetAllStatistics(p,a,b,c)
  161. #define IDP8SimControl_ClearAllStatistics(p,a)            (p)->lpVtbl->ClearAllStatistics(p,a)
  162.  
  163. #else // C++
  164.  
  165. #define IDP8SimControl_QueryInterface(p,a,b)            (p)->QueryInterface(a,b)
  166. #define IDP8SimControl_AddRef(p)                        (p)->AddRef()
  167. #define IDP8SimControl_Release(p)                        (p)->Release()
  168. #define IDP8SimControl_Initialize(p,a)                    (p)->Initialize(a)
  169. #define IDP8SimControl_Close(p,a)                        (p)->Close(a)
  170. #define IDP8SimControl_GetAllParameters(p,a,b,c)        (p)->GetAllParameters(p,a,b,c)
  171. #define IDP8SimControl_SetAllParameters(p,a,b,c)        (p)->SetAllParameters(p,a,b,c)
  172. #define IDP8SimControl_GetAllStatistics(p,a,b,c)        (p)->GetAllStatistics(p,a,b,c)
  173. #define IDP8SimControl_ClearAllStatistics(p,a)            (p)->ClearAllStatistics(p,a)
  174.  
  175. #endif
  176.  
  177.  
  178.  
  179. /****************************************************************************
  180.  *
  181.  * DP8Sim Control return codes
  182.  *
  183.  * Errors are represented by negative values and cannot be combined.
  184.  *
  185.  ****************************************************************************/
  186.  
  187. #define _DP8SIMH_FACILITY_CODE                0x015
  188. #define _DP8SIMH_HRESULT_BASE                0xE000
  189.  
  190. #define MAKE_DP8SIMSUCCESS(code)            MAKE_HRESULT(0, _DP8SIMH_FACILITY_CODE, (code + _DP8SIMH_HRESULT_BASE))
  191. #define MAKE_DP8SIMFAILURE(code)            MAKE_HRESULT(1, _DP8SIMH_FACILITY_CODE, (code + _DP8SIMH_HRESULT_BASE))
  192.  
  193.  
  194.  
  195. #define DP8SIM_OK                            S_OK
  196.  
  197. #define DP8SIMERR_ALREADYINITIALIZED        MAKE_DP8SIMFAILURE(0x10)
  198. #define DP8SIMERR_GENERIC                    E_FAIL
  199. #define DP8SIMERR_INVALIDFLAGS                MAKE_DP8SIMFAILURE(0x20)
  200. #define DP8SIMERR_INVALIDOBJECT                MAKE_DP8SIMFAILURE(0x30)
  201. #define DP8SIMERR_INVALIDPARAM                E_INVALIDARG
  202. #define DP8SIMERR_INVALIDPOINTER            E_POINTER
  203. #define DP8SIMERR_MISMATCHEDVERSION            MAKE_DP8SIMFAILURE(0x40)
  204. #define DP8SIMERR_NOTINITIALIZED            MAKE_DP8SIMFAILURE(0x50)
  205. #define DP8SIMERR_OUTOFMEMORY                E_OUTOFMEMORY
  206.  
  207.  
  208.  
  209.  
  210.  
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214.  
  215. #endif // __DP8SIM_H__
  216.  
  217.